from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import PermissionsMixin
from django.db import models


# Create your models here.

class User(AbstractBaseUser, PermissionsMixin):
    USERNAME_FIELD = 'username'

    username = models.CharField(max_length=16, primary_key=True)

    identity_c = models.CharField(max_length=2, choices=((u'1', u'teacher'), (u'0', u'student')), default=u'1')

    name = models.CharField(max_length=16, null=True)
    age = models.SmallIntegerField(default=18)
    tel = models.CharField(max_length=11, null=True)
    dl_type = (
        (u'c1', u'c1 driving license'),
        (u'c2', u'c2 driving license'),
    )
    driving_license_type = models.CharField(max_length=2, choices=dl_type, default=u'c1')

    is_buy = models.BooleanField(default=False)

    class Meta:
        db_table = 'user'  # 这里最好起一个和Django默认表不同的名字

    def __str__(self):
        return self.username.__str__()



# try:
#     for i in range(20):
#         User.objects.create(
#             username='T'+str(i),
#             identity_c='1',
#             name='T'+str(i),
#             age=20,
#             tel='1111111111',
#             password='111111'
#         )
#
# except:
#     pass


